package com.subang.function.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.subang.function.mapper.SbStudyMarkMapper;
import com.subang.function.domain.SbStudyMark;
import com.subang.function.service.ISbStudyMarkService;

/**
 * 学习打卡Service业务层处理
 * 
 * @author subei
 * @date 2025-03-27
 */
@Service
public class SbStudyMarkServiceImpl implements ISbStudyMarkService 
{
    @Autowired
    private SbStudyMarkMapper sbStudyMarkMapper;

    /**
     * 查询学习打卡
     * 
     * @param studyMarkId 学习打卡主键
     * @return 学习打卡
     */
    @Override
    public SbStudyMark selectSbStudyMarkByStudyMarkId(String studyMarkId)
    {
        return sbStudyMarkMapper.selectSbStudyMarkByStudyMarkId(studyMarkId);
    }

    /**
     * 查询学习打卡列表
     * 
     * @param sbStudyMark 学习打卡
     * @return 学习打卡
     */
    @Override
    public List<SbStudyMark> selectSbStudyMarkList(SbStudyMark sbStudyMark)
    {
        return sbStudyMarkMapper.selectSbStudyMarkList(sbStudyMark);
    }


    public List<SbStudyMark> selectTodaySbStudyMarkList(SbStudyMark sbStudyMark)
    {
        return sbStudyMarkMapper.selectTodaySbStudyMarkList(sbStudyMark);
    }

    @Override
    public List<SbStudyMark> selectTodaySbUnStudyMarkList(SbStudyMark sbStudyMark) {
        return sbStudyMarkMapper.selectTodaySbUnStudyMarkList(sbStudyMark);
    }

    /**
     * 新增学习打卡
     * 
     * @param sbStudyMark 学习打卡
     * @return 结果
     */
    @Override
    public int insertSbStudyMark(SbStudyMark sbStudyMark)
    {
        return sbStudyMarkMapper.insertSbStudyMark(sbStudyMark);
    }

    /**
     * 修改学习打卡
     * 
     * @param sbStudyMark 学习打卡
     * @return 结果
     */
    @Override
    public int updateSbStudyMark(SbStudyMark sbStudyMark)
    {
        return sbStudyMarkMapper.updateSbStudyMark(sbStudyMark);
    }

    /**
     * 批量删除学习打卡
     * 
     * @param studyMarkIds 需要删除的学习打卡主键
     * @return 结果
     */
    @Override
    public int deleteSbStudyMarkByStudyMarkIds(String[] studyMarkIds)
    {
        return sbStudyMarkMapper.deleteSbStudyMarkByStudyMarkIds(studyMarkIds);
    }

    /**
     * 删除学习打卡信息
     * 
     * @param studyMarkId 学习打卡主键
     * @return 结果
     */
    @Override
    public int deleteSbStudyMarkByStudyMarkId(String studyMarkId)
    {
        return sbStudyMarkMapper.deleteSbStudyMarkByStudyMarkId(studyMarkId);
    }

    /**
     * 根据用户ID集合统计今天打卡的人数
     *
     * @param userIds 用户ID集合
     * @return 今天打卡的人数
     */
    @Override
    public long countTodayMarkedUsersByIds(List<Long> userIds) {
        return sbStudyMarkMapper.countTodayMarkedUsersByIds(userIds);
    }

    @Override
    public List<SbStudyMark> selectTodayUnmarkedUsersByGroup(String groupId)
    {
        return sbStudyMarkMapper.selectTodayUnmarkedUsersByGroup(groupId);
    }

    @Override
    public List<SbStudyMark> selectYesterdayUnmarkedUsersByGroup(String groupId) {
        return sbStudyMarkMapper.selectYesterdayUnmarkedUsersByGroup(groupId);
    }

    @Override
    public List<SbStudyMark> groupMonthUnPunchList(String groupId) {
        return sbStudyMarkMapper.groupMonthUnPunchList(groupId);
    }

    @Override
    public List<SbStudyMark> sumMonthStudyDurationByGroup(String groupId) {
        return sbStudyMarkMapper.sumMonthStudyDurationByGroup(groupId);
    }

    public List<SbStudyMark> sumMonthQuestionCountByGroup(String groupId) {
        return sbStudyMarkMapper.sumMonthQuestionCountByGroup(groupId);
    }

    @Override
    public List<Map<String, Object>> rankingInfo(Map<String, Object> params) {
        return sbStudyMarkMapper.rankingInfo(params);
    }

}
